#e
#Title[VuԂ̉̓e -Lunatic-v]
#Text[ՓxLunaticB]
#ScriptVersion[2]

script_enemy_main {
	let name	= "VuԂ̉̓e -Lunatic-v";
	let imgHonoka=GetCurrentScriptDirectory~"img\honoka.png";
	let Angle	= rand_int(-1,1);

	let wIni = 120;
	
	///////////////////////////////////////////////////////////

	@Initialize{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
	LoadGraphic(imgHonoka);
	    
        SetMovePosition02(GetCenterX(), GetCenterY(), wIni);
        SetLife(5000);
        SetTimer(61);
	SetScore(500000);
        SetDamageRate(100, 20);
	SetInvincibility( 260 );

	TMain();
	TMain2();
	TMain3();

	}
		
	@MainLoop{
	    SetCollisionA(GetX, GetY, 32);
	    SetCollisionB(GetX, GetY, 16);



	    yield;
	}
	
	@DrawLoop{
	    SetTexture(imgHonoka);
	    DrawGraphic(GetX(), GetY());
	    if(GetSpeedX()==0){SetGraphicRect(64,1,127,64);}
	    else if(GetSpeedX()>0){SetGraphicRect(192,1,255,64);}
	    else if(GetSpeedX()<0){SetGraphicRect(128,1,191,64);}
	}
		
	@Finalize{
	    DeleteGraphic(imgHonoka);
	}

	task TMain{

	    yield;
	    loop(wIni){ yield; }

	    loop{
	    if(Angle == 0){
	    Angle = 1;
	    }
	    huusya;
	    loop(500){ yield; }
	    Angle = rand_int(-1,1);
	    }
	}

	task TMain2{

	    yield;
	    loop(wIni){ yield; }

	    loop{
	    konoha;
	    loop(1.5){ yield; }
	    }
	}

	task TMain3{

	    yield;
	    loop(wIni){ yield;}

	    loop{
	    usagi;
	    loop(45){ yield; }
	    }
	}


	//////////////////////////////////////////////////////////

	sub huusya{

	let Base	= 0;
	let Way		= 8;
	let BulletType	= GREEN01;
	let Delay	= 0;

	    CreateLaserB(001, 200, 10, BulletType, Delay);
	    SetLaserDataB(001, 0, 0, 0, 0, 0, 0, Base, Angle);
	    CreateLaserB(002, 200, 10, BulletType, Delay);
	    SetLaserDataB(002, 0, 0, 0, 0, 0, 0, Base + 90, Angle);
	    CreateLaserB(003, 200, 10, BulletType, Delay);
	    SetLaserDataB(003, 0, 0, 0, 0, 0, 0, Base + 180, Angle);
	    CreateLaserB(004, 200, 10, BulletType, Delay);
	    SetLaserDataB(004, 0, 0, 0, 0, 0, 0, Base + 270, Angle);
	    CreateLaserB(005, 200, 10, BulletType, Delay);
	    SetLaserDataB(005, 0, 0, 0, 0, 0, 0, Base + 315, Angle);
	    CreateLaserB(006, 200, 10, BulletType, Delay);
	    SetLaserDataB(006, 0, 0, 0, 0, 0, 0, Base + 45, Angle);
	    CreateLaserB(007, 200, 10, BulletType, Delay);
	    SetLaserDataB(007, 0, 0, 0, 0, 0, 0, Base + 135, Angle);
	    CreateLaserB(008, 200, 10, BulletType, Delay);
	    SetLaserDataB(008, 0, 0, 0, 0, 0, 0, Base + 225, Angle);
	    SetShotKillTime(001,500);
	    SetShotKillTime(002,500);
	    SetShotKillTime(003,500);
	    SetShotKillTime(004,500);
	    SetShotKillTime(005,500);
	    SetShotKillTime(006,500);
	    SetShotKillTime(007,500);
	    SetShotKillTime(008,500);
	    FireShot(001);
	    FireShot(002);
	    FireShot(003);
	    FireShot(004);
	    FireShot(005);
	    FireShot(006);
	    FireShot(007);
	    FireShot(008);
	}

	sub usagi{
	CreateShotA(002,rand(GetClipMinX,GetClipMaxX),GetClipMaxY,0);
	SetShotDataA_XY(002,0,rand(-3,3),rand(-1,-3),0,0.03,0,3,WHITE02);
	FireShot(002);
	}

	sub konoha{

	let speed = rand(1,3);
	if(GetPlayerY<GetCenterY - 120){
	speed = 40;
	if(Angle == -1){
	CreateShotA(003,GetClipMaxX,rand(GetClipMinY,GetClipMaxY),0);
	SetShotDataA(003,0,speed,rand(110,180),0,0.01,5,GREEN11);
	FireShot(003);
	CreateShotA(003,rand(GetClipMinX,GetClipMaxX),GetClipMinY,0);
	SetShotDataA(003,0,speed,rand(110,180),0,0.01,5,GREEN11);
	FireShot(003);
	}
	else if(Angle == 1){
	CreateShotA(003,GetClipMinX,rand(GetClipMinY,GetClipMaxY),0);
	SetShotDataA(003,0,speed,rand(0,70),0,0.01,5,GREEN11);
	FireShot(003);
	CreateShotA(003,rand(GetClipMinX,GetClipMaxX),GetClipMinY,0);
	SetShotDataA(003,0,speed,rand(0,70),0,0.01,5,GREEN11);
	FireShot(003);
	}
	}else{
	speed = rand(1,3);
	}

	if(Angle == -1){
	CreateShotA(003,GetClipMaxX,rand(GetClipMinY,GetClipMaxY),0);
	SetShotDataA(003,0,speed,rand(110,180),0,0.01,5,GREEN11);
	FireShot(003);
	CreateShotA(003,rand(GetClipMinX,GetClipMaxX),GetClipMinY,0);
	SetShotDataA(003,0,speed,rand(110,180),0,0.01,5,GREEN11);
	FireShot(003);
	}
	else if(Angle == 1){
	CreateShotA(003,GetClipMinX,rand(GetClipMinY,GetClipMaxY),0);
	SetShotDataA(003,0,speed,rand(0,70),0,0.01,5,GREEN11);
	FireShot(003);
	CreateShotA(003,rand(GetClipMinX,GetClipMaxX),GetClipMinY,0);
	SetShotDataA(003,0,speed,rand(0,70),0,0.01,5,GREEN11);
	FireShot(003);
	}
	else if(Angle == 0){
	CreateShotA(003,rand(GetClipMinX,GetClipMaxX),GetClipMinY,0);
	SetShotDataA(003,0,speed,rand(65,105),0,0.01,5,GREEN11);
	FireShot(003);
	CreateShotA(003,rand(GetClipMinX,GetClipMaxX),GetClipMinY,0);
	SetShotDataA(003,0,speed,rand(65,105),0,0.01,5,GREEN11);
	FireShot(003);
	}
	}


    // w t[҂
    function wait(w) {
        loop(w) { yield; }
    }
}